home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume17 / mgr / part28 < prev    next >
Encoding:
Internet Message Format  |  1989-01-19  |  52.1 KB

  1. Subject:  v17i029:  MGR, Bellcore window manager, Part28/61
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4.  
  5. Submitted-by: Stephen A. Uhler <sau@bellcore.com>
  6. Posting-number: Volume 17, Issue 29
  7. Archive-name: mgr/part28
  8.  
  9.  
  10.  
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 28 (of 61)."
  19. # Contents:  demo/icon/snap.c font-16/Ucmr15x25r misc/hp_raster.c
  20. #   src/defs.h src/new_window.c src/update.c
  21. # Wrapped by rsalz@papaya.bbn.com on Thu Nov 17 21:05:33 1988
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'demo/icon/snap.c' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'demo/icon/snap.c'\"
  25. else
  26. echo shar: Extracting \"'demo/icon/snap.c'\" \(8035 characters\)
  27. sed "s/^X//" >'demo/icon/snap.c' <<'END_OF_FILE'
  28. X/*                        Copyright (c) 1988 Bellcore
  29. X *                            All Rights Reserved
  30. X *       Permission is granted to copy or use this program, EXCEPT that it
  31. X *       may not be sold for profit, the copyright notice must be reproduced
  32. X *       on copies, and credit should be given to Bellcore where it is due.
  33. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  34. X */
  35. X/*    $Header: snap.c,v 4.5 88/08/23 10:47:42 bianchi Exp $
  36. X    $Source: /tmp/mgrsrc/demo/icon/RCS/snap.c,v $
  37. X*/
  38. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/icon/RCS/snap.c,v $$Revision: 4.5 $";
  39. X
  40. X/* snap a piece of the screen -- only works locally */
  41. X
  42. X#include <signal.h>
  43. X#include <sys/file.h>
  44. X#include "term.h"
  45. X#include "bitmap.h"
  46. X#include "dump.h"
  47. X
  48. X#define ICON   "easel"
  49. X#define SCREEN   "/dev/bwtwo0"
  50. X#define min(x,y)      ((x)>(y)?(y):(x))
  51. X#define dprintf   if(debug)fprintf
  52. X#define PRINTER   "lp"         /* default printer name */
  53. X#define CANCEL      10            /* time after which REVIEW is canceled */
  54. X
  55. Xstatic char buff[100];         /* mgr input buffer */
  56. Xstatic char cmd[100];            /* lpr command buffer */
  57. Xstatic char *name;               /* file name */
  58. Xstatic char my_host[32];            /* my-host */
  59. Xstatic char mgr_host[32];            /* mgr host */
  60. X
  61. Xstatic int debug=0;
  62. Xstatic int review=0;            /* review more set */
  63. Xstatic int func = BIT_SRC;
  64. X
  65. X#define MENU_COUNT      (sizeof(menu)/sizeof(struct menu_entry))
  66. X
  67. Xstatic struct menu_entry menu[] = {
  68. X   "print","Print\r",
  69. X   "file","File\r",
  70. X   "review =>","View\r",
  71. X   "quit","Quit\r",
  72. X};
  73. Xstatic struct menu_entry rop[] = {
  74. X   "set","-Set\r",
  75. X   "paint","-Paint\r",
  76. X   "xor","-Xor\r",
  77. X   "mask","-Mask\r",
  78. X};
  79. X
  80. Xmain(argc,argv)
  81. Xint argc;
  82. Xchar **argv;
  83. X   {
  84. X   BITMAP *screen , *tmp = (BITMAP *) 0;
  85. X   char *printer, *getenv();
  86. X
  87. X   FILE *fp;      /* file to write */
  88. X   int w,h;
  89. X   int wide,high;   /* picture size */
  90. X   int x,y;      /* window pos */
  91. X   int x1,y1;   /* sweep coords */
  92. X   int xmax, ymax;      /* display size */
  93. X   int n;
  94. X   int snapping = 0;      /* ready to snap */
  95. X   int format = OLD_BHDR;            /* new format */
  96. X   int cancel(),clean();
  97. X
  98. X   FILE *pf;
  99. X   
  100. X   ckmgrterm();
  101. X
  102. X   debug = (int) getenv("DEBUG");
  103. X
  104. X   if (argc > 1 && strcmp("-n",argv[1])==0) {
  105. X      format=NEW_BHDR;
  106. X      argc--;
  107. X      argv++;
  108. X        }
  109. X
  110. X   if (argc != 2) {
  111. X      fprintf(stderr,"Usage: snap [-n] <file>\n");
  112. X      exit(1);
  113. X      }
  114. X
  115. X   name = argv[1];
  116. X
  117. X   if ((screen = bit_open(SCREEN)) == (BITMAP *) 0) {
  118. X      fprintf(stderr,"%s: Can't find %s\n",*argv,SCREEN);
  119. X      exit(1);
  120. X      }
  121. X
  122. X   if ((fp = fopen(name, "w")) == NULL) {
  123. X      perror("fopen");
  124. X      fprintf(stderr,"%s: Can't fopen %s\n",*argv,name);
  125. X      exit(1);
  126. X      }
  127. X
  128. X   if ((printer = getenv("PRINTER")) == (char *) 0)
  129. X      printer = PRINTER;
  130. X   sprintf(cmd,"lpr -P%s -J%s -v",printer,name);
  131. X
  132. X   /* setup mgr library */
  133. X
  134. X   m_setup(0);
  135. X
  136. X   get_param(mgr_host,&xmax,&ymax,0);
  137. X   gethostname(my_host,sizeof(my_host));
  138. X
  139. X   if (strcmp(my_host,mgr_host) != 0) {
  140. X      fprintf(stderr,"%s only works on host: %s\n",
  141. X               argv[0],mgr_host);
  142. X      exit(1);
  143. X       }
  144. X
  145. X   m_push(P_FONT|P_FLAGS|P_MENU|P_POSITION);
  146. X   m_ttyset();
  147. X   signal(SIGALRM,cancel);
  148. X   signal(SIGTERM,clean);
  149. X   signal(SIGINT,clean);
  150. X   signal(SIGHUP,clean);
  151. X
  152. X   m_setmode(M_NOWRAP);
  153. X   m_setmode(M_ABS);
  154. X   m_func(B_COPY);
  155. X   m_bitfromfile(1,ICON);
  156. X   m_flush();
  157. X   m_gets(buff);
  158. X   n = sscanf(buff,"%d %d",&w,&h);
  159. X   if (n < 2) {
  160. X      fprintf(stderr,"%s: Can't find %s\n",*argv,ICON);
  161. X      clean(1);
  162. X      }
  163. X   setup(1,w,h);
  164. X   m_setevent(BUTTON_1,"S%R\r");   /* get coords */
  165. X   m_setevent(REDRAW,"Redraw\r");    /* get coords */
  166. X   m_setevent(RESHAPE,"Reshape\r");    /* get coords */
  167. X   menu_load(1,MENU_COUNT,menu);
  168. X   menu_load(2,MENU_COUNT,rop);
  169. X   m_selectmenu(1);
  170. X   m_linkmenu(1,2,2,6);
  171. X   m_clearmode(M_ACTIVATE);
  172. X
  173. X   m_flush();
  174. X   while(m_gets(buff)) {
  175. X      dprintf(stderr,"got %s\n",buff);
  176. X      switch (*buff) {
  177. X      case 'R':            /* redraw */
  178. X         setup(1,w,h);
  179. X         m_clearmode(M_ACTIVATE);
  180. X         break;
  181. X      case 'S':            /* set up to snap a picture */
  182. X         n = sscanf(buff+1,"%d %d %d %d",&x,&y,&x1,&y1);
  183. X         if (n < 4)
  184. X            break;;
  185. X         m_setmode(M_WOB);
  186. X         wide = abs(x1-x);
  187. X         high = abs(y1-y);
  188. X         x = min(x,x1);
  189. X         y = min(y,y1);
  190. X         m_push(P_MOUSE);
  191. X         if (x > 16 || y > 16)
  192. X            m_movemouse(0,0);         /* get mouse out of the picture */
  193. X         else 
  194. X            m_movemouse(xmax-17,ymax-17);
  195. X         if (review) {
  196. X            alarm(0);
  197. X            m_sendme("B review\r");                     /* synchronize review */
  198. X            }
  199. X         else {
  200. X            m_sendme("E snap\r");                     /* synchronize snap */
  201. X            snapping = 1;
  202. X            if (tmp) {
  203. X               bit_destroy(tmp);
  204. X               tmp = NULL;
  205. X               }
  206. X            tmp = bit_alloc(wide,high,BIT_NULL,1);
  207. X            }
  208. X         break;
  209. X      case 'B':               /* review the picture */
  210. X         if (review && tmp && !snapping) {
  211. X            review = 0;
  212. X            if (wide < 20 && high < 20) {
  213. X               wide = BIT_WIDE(tmp);
  214. X               high = BIT_HIGH(tmp);
  215. X               }
  216. X            bit_blit(screen,x,y,wide,high,func,tmp,0,0);
  217. X            dprintf(stderr,"review %d,%d by %d,%d\n",x,y,wide,high);
  218. X            m_pop();
  219. X            }
  220. X         m_clearmode(M_WOB);
  221. X         m_clearmode(M_ACTIVATE);
  222. X         break;
  223. X      case 'E':               /* get the picture */
  224. X         if (snapping && x!=16 && y!=16) {
  225. X            bit_blit(tmp,0,0,wide,high,BIT_SRC,screen,x,y);
  226. X            m_pop();
  227. X            m_clearmode(M_WOB);
  228. X            m_clearmode(M_ACTIVATE);
  229. X            }
  230. X         snapping = 0;
  231. X         break;
  232. X      case 'F':                  /* file it */
  233. X         if (tmp && !snapping) {
  234. X            fseek(fp,0L,0);
  235. X            ftruncate(fileno(fp),0);
  236. X        if (!bitmapwrite(fp,tmp,format) ) {
  237. X               m_push(P_ALL);
  238. X               m_font(0);
  239. X               m_size(27,3);
  240. X               m_clear();
  241. X               m_printstr("unable to write file\n");
  242. X               m_printstr(name);
  243. X               m_flush();
  244. X               sleep(3);
  245. X               m_pop();
  246. X               m_clearmode(M_ACTIVATE);
  247. X               m_flush();
  248. X               }
  249. X            dprintf(stderr,"filing\n");
  250. X            }
  251. X     fflush(fp);
  252. X         m_clearmode(M_ACTIVATE);
  253. X         break;
  254. X      case 'Q':                  /* quit */
  255. X         clean(0);
  256. X         break;
  257. X      case 'P':                  /* print */
  258. X         if (tmp && !snapping && (pf = popen(cmd,"w"))) {
  259. X                bitmapwrite(pf,tmp,format);
  260. X            dprintf(stderr,"printing [%s]\n",cmd);
  261. X            pclose(pf);
  262. X            }
  263. X         m_clearmode(M_ACTIVATE);
  264. X         break;
  265. X      case '-':                  /* set review mode*/
  266. X         if (review) 
  267. X            switch (*(buff+1)) {
  268. X               case 'S':         /* set */
  269. X                  func = BIT_SRC;
  270. X                  break;
  271. X               case 'P':         /* paint */
  272. X                  func = BIT_SRC | BIT_DST;
  273. X                  break;
  274. X               case 'X':         /* XOR */
  275. X                  func = BIT_SRC ^ BIT_DST;
  276. X                  break;
  277. X               case 'M':         /* MASK */
  278. X                  func = BIT_SRC & BIT_DST;
  279. X                  break;
  280. X               }
  281. X      case 'V':                  /* review */
  282. X         if (tmp && !snapping) {
  283. X            alarm(CANCEL);
  284. X            review++;
  285. X            m_setmode(M_WOB);
  286. X            }
  287. X         break;
  288. X         }
  289. X      m_flush();
  290. X      }
  291. X   
  292. X   clean(0);
  293. X   }
  294. X
  295. Xint clean(n)
  296. Xint n;
  297. X   {
  298. X   m_ttyreset();
  299. X   m_popall();
  300. X   exit(n);
  301. X   }
  302. X
  303. Xsetup(where,w,h)
  304. Xint where;      /* bitmap # */
  305. Xint w,h;         /* window size */
  306. X   {
  307. X   int wx,wy;    /* window position */
  308. X
  309. X   get_size(&wx,&wy,0,0);
  310. X   m_shapewindow(wx,wy,w+10,h+10);
  311. X   m_clear();
  312. X   m_bitcopyto(0,0,w,h,0,0,0,where);
  313. X   m_movecursor(w+20,h/2);
  314. X   }
  315. X
  316. Xint
  317. Xcancel()
  318. X   {
  319. X   review = 0;
  320. X   m_putchar('\007');
  321. X   m_clearmode(M_WOB);
  322. X   m_flush();
  323. X   }
  324. END_OF_FILE
  325. # end of 'demo/icon/snap.c'
  326. fi
  327. if test -f 'font-16/Ucmr15x25r' -a "${1}" != "-c" ; then 
  328.   echo shar: Will not clobber existing file \"'font-16/Ucmr15x25r'\"
  329. else
  330. echo shar: Extracting \"'font-16/Ucmr15x25r'\" \(8306 characters\)
  331. sed "s/^X//" >'font-16/Ucmr15x25r' <<'END_OF_FILE'
  332. Xbegin 644 cmr15x25r.fnt
  333. XM%@\9!8  __@&    !P                  &         /           P 
  334. XMW_^                            & &, ,&#,  , \ <  '!P        
  335. XM       <#\ < '\ _@ P'_X'\'_\#X _@             ?@   $ _X _@_\
  336. XM'_\__@_@P!@_  !F ,P & ,X!@_@_\ _@_\ _@?_F ,P!F ,P!B $__@#\< 
  337. XM#\  0    $                                                  
  338. XM                 < P#@     \__@&    'X                  /  P
  339. XM      ?P          P W_\                            & &, ,&#,
  340. XM!P,#N ^  . X               8'^ \ ?_#_X!P'_X?_'_\/^#_X       
  341. XM      _P   . __#_X__'_\__C_XP!@_  !F <P ' <X!C_X__#_X__#_X?_
  342. XMF ,P!F ,P!B $__@#\, #\  X    ,                     .       P
  343. XM                                     P P P    !^__@&    /\  
  344. XM        >       ?@ P      88          8!@ ,             $   
  345. XM           & &, ,&'^#X8#' ^  , 8               X.'1L 8## 8!@
  346. XM&  8#  <,&# 8            !PX   . P## 8P#&  P # 8P!@,  !F XP 
  347. XM'@\\!C 8P## 8P## 8 P& ,8#& ,8## , #@# .  , !\    8         !
  348. XM@   /   8  .  <#   P                   P                !@ P
  349. XM 8    #F__@&    <<          _   $#\ ?@ P       ,     !P# 88!
  350. XM@ ,             $              & &, 8,/_&,8&# >  8 ,        
  351. XM       P<#S, P!F ,# &  P!@ 88#& ,            #@<   ? P!F ,P!
  352. XMF  P & ,P!@,  !F!PP 'Q\\!F ,P!F ,P!F , P& ,8#& ,8## , # # & 
  353. XM , #N    X   8     !@   ?   8  .  <#   P                   P
  354. XM                !@ P 8    #F__@&    X,          C@& ,/_ VP P
  355. XM       ,     '\# 88!@ ,             .  !C          & &, 8,?/
  356. XMF,P&# .  8 ,              !P8#P, P!F ,# &  P!@ 88#& ,       
  357. XM     # ,   ; P!F ,P!F  P & ,P!@,  !F#@P &[LV!F ,P!F ,P!F , P
  358. XM& ,8#& ,,&!@8 & # '  , ''    \   8     !@   P   8     <#   P
  359. XM                   P                 P P P    # __@&    P,  
  360. XM        A@' <<'!VX P /     ,     ..# 8,#  ,             .  '
  361. XMCP         & &,#_^;-F,P'& ,  8 ,  P           !@8#@,  !@ ,& 
  362. XM&  P   P8#& ,              ,   ; P!F  P!F  P &  P!@,  !F' P 
  363. XM&;,V!F ,P!F ,P!F   P& ,,&& ,,&!@8 . # #  , .#@   ^   8     !
  364. XM@   P   8      #   P                   P                 P P
  365. XM P    # __@&   Q@8           P#@X8!!F8 P _P    ,     <'# 8,#
  366. XM  ,             ?  > \         & &,#_^;,#Y@#N 8  8 , !X &   
  367. XM      #@8'@,  !@ 8& &  P   P,&& ,              ,#\ Q@P!F  P!
  368. XMF  P &  P!@,  !F. P &.,S!F ,P!F ,P!F   P& ,,&& ,&, PP , # #@
  369. XM , <!P   ^ ?P8     !@   P   8      #   P#       8          P
  370. XM                 P P P    # __@& 'AA@8 P    ^!^& P!QP< #F<__
  371. XMQF8    ,!_W_ 8## 8/_  ,!X         !@[@!X /   $ "   & &, P8?,
  372. XM!Q@!X 0  X . PPP&         # 8/@,  #  8,,&  P  !@/># <#@    !
  373. XM@  8   </_ Q@P!F  P!F  P &  P!@,  !F< P &$,S!F ,P!F ,P!F   P
  374. XM& ,,&& ,&, PP 8 # !@ , X X   < _X8\ ?P#Q@?@ P >,8\ &   #!P P
  375. XM#<X9^ ?@8\ >,8X ?P'_# ,8!C ,0 C ,?_@ P P P    ' __@& /QC P!X
  376. XM   #P'_^ 8 [@/ #&,__S&,    ,'_W_P8## 8'^  ,'^ 0@#  !@ #!QP'@
  377. XM #P?_F &   &    P8/, # 'P    X . XQP&         ' 8=@,  &  P,,
  378. XM&  P  !@#X#Q\'P <  '@  >   X8#@Q@P#&  P!F  P &  P!@,  !FX P 
  379. XM&$,QAF ,P#& ,P##   P& ,&,& ,#8 9@ X # !P ,        !@,;_!_X/]
  380. XMA_X'_!_L;_ &  ,##@ P#]\;_!_X;_!_L;^ _X'_# ,8!C ,8!C ,?_@!@ P
  381. XM 8    & __@& 8;#!@#,   ' &9X 8 ? #P"&$ P"&$.' ?,.   X8## 8&&
  382. XM /\,# PP&   P &#@X>   \?_F &   &    P8'\ # /P    X . \SP&   
  383. XM      & 8Y@,  , /@8,'_@QP # !P _L'P ^  >   '@ !PP!Q@P__&  P!
  384. XMG_P_^&  __@,  !GP P & ,QAF ,__& ,__#_P P& ,&,& ,#X ?@ P #  P
  385. XM ,        !@,>#!@,,'A@8'_!@\?# &  ,#'  P#&,>#A@8>#!@\?'!@, P
  386. XM# ,<#C ,<#C , # #@ P <    & __B&$0/##@#,'_^& $8P 8 . #\ &  P
  387. XM&&&?/@_\<   <8## 8&& /\>'A@8,   8?_G@\>   \  # ,   &   !@P#^
  388. XM & <X    X . /_ &         . 9Q@,  8 /@8,'_XW\ # '\ .,'P ^ !X
  389. XM#_\!X #@QXQ@P__&  P!G_P_^&  __@,  !G@ P & ,PQF ,_\& ,_\ _X P
  390. XM& ,&,& ,#X / !@ #  X ,          ,<!C ,8#C , P# <<!@&  ,#.  P
  391. XM#&,<!C ,<!C <<#!@, P# ,,## ,.'# , & #@ P < ' 0& __C&,P.#!X&&
  392. XM'_^,  8P \ . /^ &  P'_^QXQ@<X   .8## 8#,  ,3,C ,8   ,?_C@X'@
  393. XM #P  # ,   &   !@P#/ & X<    X . '^ &         , ;A@,  P  PP,
  394. XM  8^/ & >/  ,#@ ^ '@#_\ > ' S^Q@PP#&  P!F  P &!\P!@,  !GP P 
  395. XM& ,PQF ,P & ,P&  8 P& ,#8&$,#8 & #@ #  8 ,          \8!C  8!
  396. XMC , P# ,8!@&  ,#<  P#&,8!C ,8!C ,8 !@  P# ,.'# ,'.# , , !@ P
  397. XM 8 /@0& __CF<P&' <&&  &,  PP!\ . <' &  P'_^PPS ,P   &8## 8#,
  398. XM  ,QXW_^__W_^ 8!QP!X / ?_A@8   &   !@P#/@, X<P   X . #\'_^  
  399. XM#_\   < ?!@, !@  8P,  ,X# & 8#  ,   < >     '@. S&S_XP!F  P!
  400. XMF  P &!\P!@,  !FX P & ,P9F ,P & ,P&  , P& ,#8&$,&, & #  #  <
  401. XM ,         /\8!C  8!C_\ P# ,8!@&  ,#\  P#&,8!C ,8!C ,8 !_P P
  402. XM# ,&&# ,#\# , 8  P P P ?PP& __AF8P&' .,#  &/X PP#L / P# &  P
  403. XM&&&PPS ,P   &8## 8#,  ,PPW_^__W_^ P [@ > \ ?_A@8   &   '_\#-
  404. XM@,XX.P   8 , '^'_^  #_\   8 >!@, #   8__@ ,P!@, P!@ ,     > 
  405. XM    '@, S&S_XP!F  P!F  P & ,P!@,  !F< P & ,P9F ,P & ,P#  , P
  406. XM& ,#8&.,&, & &  #  , ,        !_,8!C  8!C_\ P# ,8!@&  ,#^  P
  407. XM#&,8!C ,8!C ,8  _X P# ,'.# ,!X# , P  P P P 9Y@. __AVXP&' .,#
  408. XM  &,  PP'& + P# &  P"&$PPS ,P   &8## 8!X  ,QXS ,8   ,?_@?  '
  409. XMCP    PP       '_\;-@9\X.P   8 , /_ &         X <!@, &   ,__
  410. XM@ ,P!@, P!@ ,     '@#_\ > , S_C 8P!F  P!F  P & ,P!@,  !F. P 
  411. XM& ,P-F ,P & ,P#  , P& ,!P&?,,& & .  #  . ,        #@,8!C  8!
  412. XMC   P# ,8!@&  ,#G  P#&,8!C ,8!C ,8   , P# ,#,#&,#\# ,!@  P P
  413. XM P P_@, __@VPP.' .8!@ &,  P8.& + P# &   #&,QXS ,X   .8## 8!X
  414. XM  ,3,A@8,   8?_@.  !C     PP       #!@?/@;&X'@   8 , \SP&   
  415. XM   #@ P \!@, , & , ,& ,P!@8 P!F ,#@   !X#_\!X   Q_# 8P!F ,P!
  416. XMF  P & ,P!@, P!F' P & ,P-F ,P &!LP#& , P& ,!P&[L,& & ,  #  &
  417. XM ,        # ,8!C  8!C   P# ,8!@&  ,##@ P#&,8!C ,8!C ,8   , P
  418. XM# ,#\#/,'.# ,#   P P P @? , __@?@0/' .8!@  & !@8<# + X' &   
  419. XM!F8?/C 8<   <8##@X!X  ,>'@PP&   P&  .      ?_@9@       #!@/_
  420. XM S&<'@   8 , XQP& #@   'P!P \#@, 8 & , ,& ,P!@8 P!F ,'P <  >
  421. XM   '@   X ' <P!F ,P!F  P & ,P!@, P!F#@P & ,P'F ,P &!\P#& , P
  422. XM& ,!P'Q\8# & 8  #  ' ,        # <<!C ,8#C , P# <8!@&  ,#!P P
  423. XM#&,8!C ,<!C <8 !@, P# <!X#9L.'# <&  !@ P 8 @. , __@?@8;'P<P 
  424. XMP  ' !@88# / >. & __P_P.'!AP.   X8#!QP P  ,,# 0@#  !@,  $   
  425. XM   ?_@9@   &   &# '^ S&>/P   , 8 PPP& 'P   'P!@ N' , P # 8 ,
  426. XM# 88# P 8## 8'P ^  '@  >  . <!V ,P## 8P#&  P # 8P!@, 8#&!PP 
  427. XM& ,P'C 8P # XP## 8 P# 8 @'@\8# & X  #  # ,        # \>#!@,,'
  428. XMA@, P!@\8!@&  ,# X P#&,8!C ,>#!@\8 !@, P!A\!X#P\<#AA\,  !@ P
  429. XM 8    , __@/ /QW_XP P  #P!@,P!@& ?^ & __P/   !_@'_W_P8# _@ P
  430. XM'_\'^        8  $ ?_C_\   /    &   &# #,!A\/\P   . X !X & 'P
  431. XM   'P#@ '^#_P__C_X ,#_X?_ P ?_#_X'P ^  !@  8  . /_F ,__#_X__
  432. XM'_\P #_XP!@_ ?_& X__F ,P#C_XP #_\P!C_X P#_X @' <P!@& __@#\ #
  433. XMC\        !_L;_!_X/]A_X P!_L8!@&  ,# < P#&,8!A@8;_!_L8  _X ?
  434. XM!_L P#@<8!A_L?_@ P P P    , __@& '@6?P@ 0   ^!@,P!P  'X &   
  435. XM      ? !_W_ 8# .  P'_^!X             ?_C_\   &    &   &# #,
  436. XM!@X#X    '!P  P & #P   #@#  #\#_P__@_@ , _@'\ P '\ _@#@ >   
  437. XM      . #^& ,_X _@_\'_\P  _@P!@_ '\& 8__F ,P#@_@P  _NP!@_@ P
  438. XM _@ @& ,P!@& __@#\ !C\         _,8\ ?P#Q@?P P >,8!@&  ,# , P
  439. XM#&,8!A_X8\ >,8  ?P / >, P# ,0 @>,?_@ < P#@    , __@    &    
  440. XM                                                            
  441. XM                                      !P                    
  442. XM                .                                           
  443. XM            &                                               
  444. XM       ,      ,           _@8   ,                   ,      P
  445. XM     &8 __@    &                                            
  446. XM                                                          !@
  447. XM                                    ,                       
  448. XM                                                            
  449. XM                           ,      ,             8   ,       
  450. XM            ,      P     &8 __@    &                        
  451. XM                                                            
  452. XM                  #                                     8   
  453. XM                                                            
  454. XM                         '__@                !@8      ,     
  455. XM        8   ,                 !@8      P     &8 __@    &    
  456. XM                                                            
  457. XM                                      "                     
  458. XM                0                                           
  459. XM                                             '__@           
  460. XM     !_X     #X             8   ,                 !_X      P
  461. XM     #X __@    &                                            
  462. XM                                                            
  463. XM                                                            
  464. XM                                                            
  465. XM                          _@     #P             8   ,       
  466. X5           _@      P     !P 
  467. Xend
  468. END_OF_FILE
  469. # end of 'font-16/Ucmr15x25r'
  470. fi
  471. if test -f 'misc/hp_raster.c' -a "${1}" != "-c" ; then 
  472.   echo shar: Will not clobber existing file \"'misc/hp_raster.c'\"
  473. else
  474. echo shar: Extracting \"'misc/hp_raster.c'\" \(8273 characters\)
  475. sed "s/^X//" >'misc/hp_raster.c' <<'END_OF_FILE'
  476. X/*                        Copyright (c) 1988 Bellcore
  477. X *                            All Rights Reserved
  478. X *       Permission is granted to copy or use this program, EXCEPT that it
  479. X *       may not be sold for profit, the copyright notice must be reproduced
  480. X *       on copies, and credit should be given to Bellcore where it is due.
  481. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  482. X */
  483. X/* Raster print filter for hp laser printer */
  484. X
  485. X/***********************************************************************
  486. X * $Header: hp_raster.c,v 1.3 88/07/15 14:34:13 sau Exp $
  487. X * $Locker:  $
  488. X * $Source: /tmp/mgrsrc/misc/RCS/hp_raster.c,v $
  489. X * $Log:    hp_raster.c,v $
  490. X * Revision 1.3  88/07/15  14:34:13  sau
  491. X * Add new bitmap format (handles both formats now )
  492. X * 
  493. X * Revision 1.1  88/07/15  14:32:21  sau
  494. X * Initial revision
  495. X * 
  496. X * Revision 1.2  88/07/08  08:25:43  sau
  497. X * 
  498. X * 
  499. X * Revision 1.1  88/07/08  08:16:57  sau
  500. X * Initial revision
  501. X * 
  502. X * Revision 1.1  88/07/08  08:14:22  sau
  503. X * Initial revision
  504. X * 
  505. X * Revision 1.5  87/07/14  20:10:40  sau
  506. X * Eliminate training white space on a line by line basis
  507. X * 
  508. X * Revision 1.4  87/06/25  11:03:29  sau
  509. X * Auto scaling, lpr version
  510. X * 
  511. X ***********************************************************************/
  512. X
  513. X/* avoid complaints from "lint" */
  514. X
  515. X#ifndef lint
  516. Xstatic char     RCS_Id[] = "$Header: hp_raster.c,v 1.3 88/07/15 14:34:13 sau Exp $";
  517. X#endif
  518. X#include <stdio.h>
  519. X#include "dump.h"
  520. X
  521. X#define GET_OPT(i)    \
  522. X    strlen(argv[i])>2 ? argv[i]+2 : argv[++i]
  523. X#define WIDTH16(w)    ((((w)+15)&~0xf)>>3)        /* old bitmap format */
  524. X#define WIDTH8(w)    ((w)>>3)                            /* new bitmap format */
  525. X#define Min(x,y)    ((x)<(y)?(x):(y))
  526. X
  527. X#define DOTS_WIDE    (8*300)        /* dots across page */
  528. X#define DOTS_HIGH    (10*300+150)    /* dots down page */
  529. X#define WIDE        1152        /* default # pixels/row */
  530. X#define HIGH        900        /* default # rows/screen */
  531. X#define HI_RES        300        /* dots per inch */
  532. X#define MED_RES        150        /* dots per inch */
  533. X#define LOW_RES        100        /* dots per inch */
  534. X#define MIN_RES        75        /* dots per inch */
  535. X#define MAX        4000        /* maximum row size */
  536. X#define BORDER        3        /* default size of border */
  537. X#define STRIP        3        /* white strip for viewgrqaphs */
  538. X
  539. X/* printer macros */
  540. X
  541. X#define set_pos(xp,yp) \
  542. X    printf("\033*p%dy%dX",yp,xp)    /* set cursor position (dots) */
  543. X#define set_res(res) \
  544. X    printf("\033*t%dR",res)        /* set dots/inch */
  545. X#define reset() \
  546. X    printf("\033E")            /* reset the printer */
  547. X#define manual_feed() \
  548. X    printf("\033&l2H")        /* select manual feed */
  549. X#define start_graphics() \
  550. X    printf("\033*r1A")        /* set raster mode */
  551. X#define set_row(wide) \
  552. X    (printf("\033*b%dW",wide), fflush(stdout))
  553. X#define end_graphics() \
  554. X    printf("\033*rB")        /* end graphics mode */
  555. X#define set_copies(n) \
  556. X    printf("\033&l%dX",Min(n,99))    /* set copy count */
  557. X#define set_rule(w,h) \
  558. X    printf("\033*c%da%dB",w,h)    /* set rule size */
  559. X#define print_rule(type) \
  560. X    printf("\033*c%dP",type)    /* print 'type' rule */
  561. X
  562. Xunion {
  563. X    struct b_header new;
  564. X    struct old_b_header old;
  565. X    char type[2];
  566. X    } h_buff, *head = &h_buff;
  567. X
  568. Xmain(argc,argv)
  569. Xint argc;
  570. Xchar **argv;
  571. X   {
  572. X   register int k,i,j=0;
  573. X   int n;                /* last non-white space */
  574. X   unsigned char buff[MAX/8];        /* graphics line buffer */
  575. X   int wide = WIDE, high = HIGH;    /* raster size */
  576. X   int no_head=0;            /* no raster header found */
  577. X   int reverse=0;            /* reverse bits */
  578. X   int pause = 0;            /* for vgrafs */
  579. X   int manual = 0;            /* select manual feed */
  580. X   int copies = 0;            /* set copy count */
  581. X   int border = 0;            /* draw border around picture */
  582. X   int res = MED_RES;            /* resolution dots/in */
  583. X   int force_res=0;            /* force resolution */
  584. X   int x0,y0;                /* starting raster coord */
  585. X   int x=0,y=0;                    /* user supplied coords */
  586. X   int bytes;                /* raster line size */
  587. X    int depth=1;            /* bitmap depth */
  588. X    char type[2];            /* bitmap type */
  589. X
  590. X   /* check arguments */
  591. X
  592. X   for(i=1;i<argc;i++) {
  593. X      if (*argv[i] == '-')
  594. X         switch (argv[i][1]) {
  595. X            case 'X':                /* x coord */
  596. X               x = atoi(GET_OPT(i));
  597. X               break;
  598. X            case 'Y':                /* y coord */
  599. X               y = atoi(GET_OPT(i));
  600. X               break;
  601. X            case 'r':                /* reverse bits */
  602. X               force_res = atoi(GET_OPT(i));
  603. X               break;
  604. X            case 'm':                /* set manual feed */
  605. X               manual++;
  606. X               break;
  607. X            case 'n':                /* login (from lpd )*/
  608. X               GET_OPT(i);
  609. X               break;
  610. X            case 'h':                /*  host (from lpd) */
  611. X               GET_OPT(i);
  612. X               break;
  613. X            case 'y':                /* specify border- for lpd */
  614. X               border = Min(32,atoi(GET_OPT(i)));
  615. X               break;
  616. X            case 'b':                /* set border size */
  617. X               if (argv[i][2])
  618. X                  border = atoi(&argv[i][2]);
  619. X               else
  620. X                  border = BORDER;
  621. X               break;
  622. X            case 'c':                /* set copies */
  623. X               copies = atoi(GET_OPT(i));
  624. X               break;
  625. X            case 'p':                /* set pause */
  626. X            case 'x':                /* for lpd */
  627. X               pause = atoi(GET_OPT(i));
  628. X               break;
  629. X            default:
  630. X               fprintf(stderr,"%s: bad flag %c ignored\n",argv[0],argv[i][1]);
  631. X            }
  632. X      }
  633. X
  634. X   /* get header */
  635. X
  636. X   if (!no_head) {
  637. X      read(0,head->type,2);                /* get magic number */
  638. X      if (B_ISHDR16(&head->old)) {        /* old style header */
  639. X         read(0,head->type+2,B_OHSIZE-2);
  640. X         B_GETOLDHDR(&head->old,wide,high);
  641. X           bytes = WIDTH16(wide);
  642. X            }
  643. X        else if (B_ISHDR8(&head->new)) {        /* new style header */
  644. X         read(0,head->type+2,B_HSIZE-2);
  645. X         B_GETHDR8(&head->new,wide,high,depth);
  646. X           bytes = WIDTH8(wide);
  647. X            }
  648. X      else {        /* assume 16 bit alignment , no header */
  649. X         wide=WIDE,high=HIGH-1;
  650. X         Read(0,buff,WIDTH16(wide)-2);        /* oops ! lose 1st line */
  651. X           bytes = WIDTH16(wide);
  652. X         }
  653. X      }
  654. X
  655. X    if (depth != 1) {
  656. X        fprintf(stderr,"Sorry, Can\'t handle 8-bit pixels\n");
  657. X        exit(0);
  658. X        }
  659. X
  660. X   /* compute appropriate resolution */
  661. X
  662. X   switch(Min(DOTS_WIDE/(border+wide),DOTS_HIGH/(border+high))) {
  663. X      case 0:        /* picture too big, use hi-res and go */
  664. X         /* no break - for now */
  665. X      case 1:
  666. X         res = HI_RES;
  667. X         break;
  668. X      case 2:
  669. X         res = MED_RES;
  670. X         break;
  671. X      case 3:
  672. X         res = LOW_RES;
  673. X         break;
  674. X      default:
  675. X         res = MIN_RES;
  676. X         break;
  677. X      }
  678. X
  679. X   if (force_res)
  680. X      res = force_res;
  681. X
  682. X   /* center picture */
  683. X
  684. X   if (pause>1)             /* skip white strip for viewgraphs */
  685. X      x0 = (DOTS_WIDE-HI_RES*wide/res);
  686. X   else
  687. X      x0 = (DOTS_WIDE-HI_RES*wide/res)/2;
  688. X   y0 = (DOTS_HIGH-HI_RES*high/res)/2;
  689. X
  690. X   if (x>0)
  691. X      x0 = x;
  692. X   if (y>0)
  693. X      y0 = y;
  694. X
  695. X   fprintf(stderr,"printing raster %dx%d at %d,%d - %d dots/in%s\n",
  696. X            wide,high,x0,y0,res,border ? " (bordered)":"");
  697. X
  698. X   /* setup printer */
  699. X
  700. X   reset();                    /* reset the printer */
  701. X   if (pause || manual) 
  702. X        manual_feed();                /* select manual feed */
  703. X   if (copies)
  704. X        set_copies(copies);            /* set copy count */
  705. X   set_pos(x0,y0);                /* set starting position */
  706. X   set_res(res);                /* set resolution */
  707. X   start_graphics();                /* start graphics */
  708. X
  709. X   for (i=0;i<high;i++) {
  710. X      Read(0,buff,bytes);
  711. X      for(j=bytes;j>0 && buff[j-1]==0;j--); 
  712. X      set_row(j);
  713. X      write(1,buff,j);
  714. X      }
  715. X   end_graphics();
  716. X
  717. X   /* draw borders */
  718. X
  719. X   if (border) {
  720. X      set_rule(border,2*border+high*HI_RES/res);
  721. X      set_pos(x0-border,y0-border);
  722. X      print_rule(0);                /* left edge */
  723. X      set_pos(x0+wide*HI_RES/res,y0-border);
  724. X      print_rule(0);                /* right edge */
  725. X
  726. X      set_rule(wide*HI_RES/res,border);
  727. X      set_pos(x0,y0-border);
  728. X      print_rule(0);                /* top edge */
  729. X      set_pos(x0,y0+high*HI_RES/res);
  730. X      print_rule(0);                /* bottom edge */
  731. X      }
  732. X
  733. X   printf("\n\f");
  734. X   exit(0);
  735. X   }
  736. X
  737. X/* do multiple passes for read */
  738. X
  739. XRead(fd,buff,count)
  740. Xint fd,count;
  741. Xregister char *buff;
  742. X   {
  743. X   register int sum=0,current=0;
  744. X
  745. X   while((current = read(0,buff+sum,count-sum))>0)
  746. X      sum += current;
  747. X   return(sum);
  748. X   }
  749. X
  750. X/* return index of 1st non zero byte, or bytes if entirely blank */
  751. X
  752. Xint
  753. Xfirst(buff,bytes)
  754. Xregister char *buff;
  755. Xregister int bytes;
  756. X   {
  757. X   char *start = buff+1;
  758. X   while(bytes-- > 0)
  759. X      if (*buff++) 
  760. X         break;
  761. X   return(buff-start);
  762. X   }
  763. END_OF_FILE
  764. # end of 'misc/hp_raster.c'
  765. fi
  766. if test -f 'src/defs.h' -a "${1}" != "-c" ; then 
  767.   echo shar: Will not clobber existing file \"'src/defs.h'\"
  768. else
  769. echo shar: Extracting \"'src/defs.h'\" \(8116 characters\)
  770. sed "s/^X//" >'src/defs.h' <<'END_OF_FILE'
  771. X/*                        Copyright (c) 1987 Bellcore
  772. X *                            All Rights Reserved
  773. X *       Permission is granted to copy or use this program, EXCEPT that it
  774. X *       may not be sold for profit, the copyright notice must be reproduced
  775. X *       on copies, and credit should be given to Bellcore where it is due.
  776. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  777. X */
  778. X/*    $Header: defs.h,v 4.2 88/08/12 07:40:25 sau Exp $
  779. X    $Source: /tmp/mgrsrc/src/RCS/defs.h,v $
  780. X*/
  781. Xstatic char    h_defs_[] = "$Source: /tmp/mgrsrc/src/RCS/defs.h,v $$Revision: 4.2 $";
  782. X
  783. X/* defines for mgr */
  784. X
  785. X/* configurable parameters */
  786. X#include "defines.h"
  787. X
  788. X#ifdef SYSV
  789. X#define index        strchr
  790. X#define rindex        strrchr
  791. X#endif
  792. X
  793. X#ifdef DEBUG
  794. Xextern char debug_level[];
  795. Xchar *index();
  796. X#define dprintf(x) \
  797. X    if (debug && index(debug_level,'x')) fprintf
  798. X#endif
  799. X
  800. X/* macros -- for speed */
  801. X
  802. X#ifdef FASTMOUSE
  803. X#define MoUSE(a,b)     bit_blit(screen, a, b, 16,16, \
  804. X                               BIT_SRC^BIT_DST, m_rop,0,0)
  805. X#define MOUSE_ON(a,b)    (!mouse_on && (mouse_on=1, MoUSE(a,b)) )
  806. X#define MOUSE_OFF(a,b)    ( mouse_on && (mouse_on=0, MoUSE(a,b)) )
  807. X#else
  808. X/* turn on the mouse only if it is off */
  809. X#define MOUSE_ON(a,b)     (!mouse_on && ( \
  810. X                  mouse_on=1, \
  811. X                      bit_blit(&mouse_save,0,0,16,16, \
  812. X                    BIT_SRC,screen,a,b), \
  813. X                  bit_blit(screen,a,b,16,16, \
  814. X                    BIT_SRC|BIT_DST,m_rop,0,0), \
  815. X                  bit_blit(screen,a,b,16,16, \
  816. X                      BIT_NOT(BIT_SRC)&BIT_DST,m_rop,0,16) \
  817. X                  ))
  818. X/* turn off the mouse only if it is on */
  819. X#define MOUSE_OFF(a,b)     (mouse_on && ( \
  820. X                      mouse_on=0, \
  821. X                      bit_blit(screen,a,b,16,16, \
  822. X                    BIT_SRC,&mouse_save,0,0) \
  823. X                      ))
  824. X#endif
  825. X
  826. X#define CLEAR(s,op)    bit_blit((s),0,0,BIT_WIDE(s),BIT_HIGH(s), \
  827. X            op,0,0,0);
  828. X
  829. X#define ACTIVE_ON() \
  830. X            border(active,SUM_BDR-1,1), \
  831. X            last_active = active!=last_active ? \
  832. X              ( \
  833. X              do_event(EVENT_DEACTIVATED,last_active,E_MAIN), \
  834. X              do_event(EVENT_ACTIVATED,active,E_MAIN), \
  835. X              active ) \
  836. X            : \
  837. X              last_active
  838. X                   
  839. X#define ACTIVE_OFF() \
  840. X            border(active,BLK_BDR,WH_BDR)
  841. X
  842. X#define SETMOUSEICON(x)    (m_rop = x)
  843. X
  844. X/* short hand */
  845. X
  846. X#define W(x)        (win->x)
  847. X#define BETWEEN(a,x,b)    (x)<(a)?a:((x)>(b)?b:x)
  848. X#define ACTIVE(x)    (active->x)
  849. X#define ABS(x)        ((x)>0 ? (x) : -(x))
  850. X
  851. X/* mouse buttons */
  852. X
  853. X#define BUTTON_SYS    4        /* system menu */
  854. X#define BUTTON_2    2        /* middle button (unused) */
  855. X#define BUTTON_1    1        /* right button (vi?) */
  856. X
  857. X/* Window table flags */
  858. X
  859. X#define W_ACTIVE    0x000001L    /* Window is non_occluded */
  860. X#define W_ESCAPE    0x000002L    /* An escape sequence is in progress */
  861. X#define W_STOPPED    0x000004L    /* Window is stopped ( unused ) */
  862. X#define W_REVERSE    0x000008L    /* window is white on black */
  863. X#define W_STANDOUT    0x000010L    /* window is in standout mode */
  864. X#define W_DIED        0x000020L    /* window has died */
  865. X#define W_EXPOSE    0x000040L    /* expose window upon shell output */
  866. X#define W_BACKGROUND    0x000080L    /* permit obscured window to update */
  867. X#define W_NOKILL    0x000100L    /* don't kill window upon exit */
  868. X#define W_VI        0x000200L    /* temporary vi hack -- */
  869. X#define W_TEXT        0x000400L    /* downloading text */
  870. X#define W_NOINPUT    0x000800L    /* don't accept keyboard input */
  871. X#define W_NOWRAP    0x001000L    /* don't auto wrap */
  872. X#define W_OVER        0x002000L    /* overstrike mode */
  873. X#define W_ABSCOORDS    0x004000L    /* use absolute coordinates */
  874. X#define W_MINUS        0x008000L    /* negative coord value */
  875. X#define W_SNARFABLE    0x000004L    /* ok to gather data into cut buffer */
  876. X#define W_SNARFLINES    0x010000L    /* snarf only lines */
  877. X#define W_SNARFTABS    0x020000L    /* change spaces to tabs in snarf */
  878. X#define W_SNARFHARD    0x040000L    /* snarf even if errors */
  879. X#define W_SNARFLAGS    (W_SNARFTABS | W_SNARFHARD | W_SNARFLINES)
  880. X#define W_INHERIT    0x080000L    /* inherit menus and bitmaps */
  881. X#define W_DUPKEY    0x100000L    /* duplicate key mode */
  882. X#define W_NOBUCKEY    0x200000L    /* Buckey keys (i.e. "Left-<char>" and
  883. X                    "Right-<char>") have no effect */
  884. X#define W_CLIPDONE    0x400000L    /* clip list for background update valid
  885. X                    */
  886. X
  887. X#define W_LOOK \
  888. X    (W_EXPOSE | W_BACKGROUND)    /* Window ready to accept data */
  889. X
  890. X#define W_STATE \
  891. X    (W_ESCAPE | W_TEXT)        /* terminal emulator states */
  892. X
  893. X#ifdef CUT
  894. X#define W_SAVE \
  895. X    (W_REVERSE | W_STANDOUT | W_EXPOSE | W_BACKGROUND | \
  896. X     W_VI | W_NOINPUT | W_NOWRAP | \
  897. X     W_SNARFLAGS | \
  898. X     W_OVER | W_ABSCOORDS)        /* savable flags */
  899. X#else
  900. X#define W_SAVE \
  901. X    (W_REVERSE | W_STANDOUT | W_EXPOSE | W_BACKGROUND | \
  902. X     W_VI | W_NOINPUT | W_NOWRAP | \
  903. X     W_OVER | W_ABSCOORDS)        /* savable flags */
  904. X#endif
  905. X
  906. X#define INIT_FLAGS    W_BACKGROUND    /* default window creation flags */
  907. X
  908. X/* Structure definitions */
  909. X
  910. Xtypedef struct {    /* used for text regions */
  911. X  int x,y,wide,high;
  912. X  } rectangle;
  913. X
  914. Xtypedef struct  {    /* some day */
  915. X  int x,y;
  916. X  } point;
  917. X
  918. Xtypedef struct window {        /* primary window structure */
  919. X  struct window *next;    /* next window */
  920. X  struct window *prev;    /* previous window */
  921. X  struct window *stack;    /* stack of saved window environments */
  922. X  struct window *main;    /* main window (or 0 if main window ) */
  923. X  struct window *alt;    /* alternate window ( 0 if none) */
  924. X  BITMAP *border;    /* window + border */
  925. X  BITMAP *window;    /* This is the window */
  926. X  BITMAP *save;        /* pointer to window bit-image if inactive */
  927. X  BITMAP *bitmap;    /* for use when downloading bitmaps */
  928. X  BITMAP *bitmaps[MAXBITMAPS];    /* scratchpad space */
  929. X  BITMAP *cursor;    /* bitmap of cursor (future; unused just now) */
  930. X  struct font *font;    /* this is the font */
  931. X  char *clip_list;    /* pointer to clip list for BG updates */
  932. X
  933. X  rectangle text;    /* location of text region within window */
  934. X  int x0,y0;        /* origin of window on screen */
  935. X  int x,y;        /* cursor character position */
  936. X  int gx,gy;        /* graphics cursor */
  937. X  int op;        /* raster op function (see bitmap.h)  */
  938. X  int style;        /* character style normal/inverse video */
  939. X  int background;    /* background color WOB or BOW */
  940. X  int curs_type;    /* cursor type */
  941. X
  942. X  int esc_cnt;        /* # of escape digits entered */
  943. X  int esc[MAXESC];    /* escape array (as in ESCnn,nnm) */
  944. X  int code;        /* code for text function */
  945. X  char dup;        /* char to duplicate from keyboard */
  946. X
  947. X  struct menu_state *menus[MAXMENU];    /* menus */
  948. X  short menu[2];    /* index into menus for current button 1&2 menu */
  949. X  long event_mask;    /* event mask  (see event.h) */
  950. X  char *events[MAXEVENTS];    /* place for event strings */
  951. X  char *snarf;            /* temporary snarf buffer */
  952. X
  953. X  unsigned long flags;        /* misc. window flags (see defines above) */
  954. X
  955. X  char buff[MAXSHELL];    /* shell input buffer */
  956. X  int  max;        /* the # of chars in buff */
  957. X  int  current;        /* the current char in buff */
  958. X  int  to_fd;        /* file descriptor to shell */
  959. X  int  from_fd;        /* file descriptor from shell */
  960. X  int  pid;        /* process number of the shell */
  961. X  int  setid;        /* window set id, 1..N, one per pid */
  962. X  int  num;        /* window number ( for multiple window/proc) */
  963. X            /* The window set id and the window number together
  964. X            uniquely identify a window. */
  965. X
  966. X  char tty[MAXTTY];    /* name of shell's tty */
  967. X  } WINDOW;
  968. X
  969. Xtypedef int (*function)();
  970. Xint new_window(), move_window(), destroy_window(), quit();
  971. Xint redraw();
  972. Xint sig_child(), catch();
  973. X
  974. X/* static data items (described in data.c) */
  975. X
  976. Xextern short c_arrow1[];
  977. Xextern short c_box[];
  978. Xextern short pat_data[];
  979. Xextern char *full_menu[];
  980. Xextern char *main_menu[];
  981. Xextern char *active_menu[];
  982. Xextern char *test_menu[];
  983. Xchar *quit_menu[];
  984. Xextern function full_functions[];
  985. Xextern function main_functions[];
  986. Xextern function active_functions[];
  987. X
  988. Xextern BITMAP *m_rop;
  989. Xextern int next_window;
  990. Xextern BITMAP pattern, mouse_box, mouse_arrow, mouse_cup, mouse_cross,mouse_cut;
  991. Xextern BITMAP mouse_save, mouse_not;
  992. Xextern struct font *font;
  993. Xextern BITMAP *screen;
  994. Xextern int mask;
  995. Xextern int poll;
  996. Xextern int rev_ops[];
  997. Xextern WINDOW *active;
  998. Xextern WINDOW *last_active;
  999. Xextern int button_state;
  1000. Xextern mouse, mousex, mousey, mouse_on;
  1001. Xextern int debug;
  1002. Xextern char *fontlist[], *font_dir;
  1003. Xextern char *icon_dir;
  1004. Xextern char *snarf;
  1005. Xextern char *message;
  1006. Xextern char *start_command;
  1007. Xextern char *init_command;
  1008. Xextern int id_message;
  1009. Xextern short buckey_map;
  1010. Xextern unsigned int init_flags;
  1011. Xextern char *version[];
  1012. END_OF_FILE
  1013. # end of 'src/defs.h'
  1014. fi
  1015. if test -f 'src/new_window.c' -a "${1}" != "-c" ; then 
  1016.   echo shar: Will not clobber existing file \"'src/new_window.c'\"
  1017. else
  1018. echo shar: Extracting \"'src/new_window.c'\" \(7968 characters\)
  1019. sed "s/^X//" >'src/new_window.c' <<'END_OF_FILE'
  1020. X/*                        Copyright (c) 1987 Bellcore
  1021. X *                            All Rights Reserved
  1022. X *       Permission is granted to copy or use this program, EXCEPT that it
  1023. X *       may not be sold for profit, the copyright notice must be reproduced
  1024. X *       on copies, and credit should be given to Bellcore where it is due.
  1025. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1026. X */
  1027. X/*    $Header: new_window.c,v 4.2 88/08/12 07:41:02 sau Exp $
  1028. X    $Source: /tmp/mgrsrc/src/RCS/new_window.c,v $
  1029. X*/
  1030. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/src/RCS/new_window.c,v $$Revision: 4.2 $";
  1031. X
  1032. X/* Create a new window */
  1033. X
  1034. X#include "bitmap.h"
  1035. X#include <fcntl.h>
  1036. X#include <stdio.h>
  1037. X#include "defs.h"
  1038. X#include "window.h"
  1039. X#include "font.h"
  1040. X#include "menu.h"
  1041. X
  1042. X/* sweep out a new window */
  1043. X
  1044. Xint new_window()
  1045. X   {
  1046. X   register WINDOW *win;
  1047. X   int dx=16,dy=16;
  1048. X   char *malloc();
  1049. X   WINDOW * insert_win();
  1050. X
  1051. X   if (next_window >= MAXWIN)
  1052. X       return(-1);
  1053. X   SETMOUSEICON(&mouse_box);
  1054. X   move_mouse(screen,mouse,&mousex,&mousey,0);
  1055. X   SETMOUSEICON(&mouse_arrow);
  1056. X   get_rect(screen,mouse,mousex,mousey,&dx,&dy,0);
  1057. X   do_button(0);
  1058. X
  1059. X   return( create_window( mousex, mousey, dx, dy, -1, 0 ) );
  1060. X   }
  1061. X
  1062. X/* insert a new window into the window list */
  1063. X
  1064. XWINDOW *
  1065. Xinsert_win(win)
  1066. XWINDOW *win;
  1067. X   {
  1068. X   char *malloc();
  1069. X
  1070. X   if (win == (WINDOW *) 0 &&
  1071. X           (win = (WINDOW *) malloc(sizeof(WINDOW))) == (WINDOW *) 0) {
  1072. X      if( debug )
  1073. X     fprintf(stderr,"Can't malloc window space\n");
  1074. X      return(win);
  1075. X      }
  1076. X
  1077. X   if (active) {
  1078. X      W(prev) = ACTIVE(prev);
  1079. X      ACTIVE(prev) = win;
  1080. X      W(next) = active;
  1081. X      }
  1082. X   else {
  1083. X      W(prev) = win;
  1084. X      W(next) = (WINDOW *) 0;
  1085. X      }
  1086. X   return(win);
  1087. X   }
  1088. X
  1089. X/* create a new window given coords */
  1090. X
  1091. Xint
  1092. Xcreate_window(x,y,dx,dy,font_num,argv)
  1093. Xint x,y,dx,dy;
  1094. Xint font_num;
  1095. Xchar **argv;
  1096. X   {
  1097. X   register WINDOW * win;
  1098. X   WINDOW * insert_win();
  1099. X
  1100. X   if (next_window >= MAXWIN)
  1101. X       return(-1);
  1102. X   if (check_window(x,y,dx,dy,font_num) == 0)
  1103. X      return(-1);
  1104. X
  1105. X   /* alloc window space */
  1106. X
  1107. X   if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == (WINDOW *) 0) {
  1108. X      fprintf(stderr,"Can't malloc window space\n");
  1109. X      return(-1);
  1110. X      }
  1111. X      
  1112. X   if ((W(pid) = get_command(argv,&W(from_fd))) < 0) {
  1113. X      free(win);
  1114. X      fprintf(stderr,"Can't get a pty\n");
  1115. X      return(-1);
  1116. X      }
  1117. X   W(to_fd) = W(from_fd);
  1118. X   W(setid) = next_windowset_id();
  1119. X
  1120. X   active = insert_win(win);
  1121. X
  1122. X   make_window(screen,x,y,dx,dy,font_num,"");
  1123. X   return(0);
  1124. X   }
  1125. X
  1126. X/* create a new window given coords , with only 1/2 a ptty */
  1127. X
  1128. Xchar *
  1129. Xhalf_window(x,y,dx,dy,font_num)
  1130. Xint x,y,dx,dy;
  1131. Xint font_num;
  1132. X   {
  1133. X   register WINDOW * win;
  1134. X   WINDOW * insert_win();
  1135. X   char *half_open();
  1136. X   char *tty;
  1137. X
  1138. X   if (next_window >= MAXWIN)
  1139. X       return(NULL);
  1140. X   if (check_window(x,y,dx,dy,font_num) == 0)
  1141. X      return(NULL);
  1142. X
  1143. X   /* alloc window space */
  1144. X
  1145. X   if ((win = (WINDOW *) malloc(sizeof(WINDOW))) == (WINDOW *) 0) {
  1146. X      fprintf(stderr,"Can't malloc window space\n");
  1147. X      return(NULL);
  1148. X      }
  1149. X      
  1150. X   if ((tty = half_open(&W(from_fd))) == NULL) {
  1151. X      free(win);
  1152. X      fprintf(stderr,"Can't get a pty\n");
  1153. X      return(NULL);
  1154. X      }
  1155. X
  1156. X   W(setid) = next_windowset_id();
  1157. X   active = insert_win(win);
  1158. X
  1159. X   W(to_fd) = W(from_fd);
  1160. X   make_window(screen,x,y,dx,dy,font_num,"");
  1161. X   W(pid) = 1;
  1162. X   W(flags) |= W_NOKILL;
  1163. X
  1164. X   return(tty);
  1165. X   }
  1166. X
  1167. X/* check window size */
  1168. X
  1169. Xint
  1170. Xcheck_window(x,y,dx,dy,fnt)
  1171. Xint x, y, dx, dy;
  1172. Xint fnt;
  1173. X   {
  1174. X   struct font *curr_font, *Get_font();
  1175. X
  1176. X   if (dx<0)
  1177. X      x += dx, dx = -dx;
  1178. X   if (dy<0)
  1179. X      y += dy, dy = -dy;
  1180. X   
  1181. X   if (x >= BIT_WIDE(screen) || y >= BIT_HIGH(screen))
  1182. X       return(0);
  1183. X
  1184. X   if (x + dx >= BIT_WIDE(screen))
  1185. X      dx = BIT_WIDE(screen)-x;
  1186. X
  1187. X   if (y + dy >= BIT_HIGH(screen))
  1188. X      dy = BIT_HIGH(screen)-y;
  1189. X
  1190. X   curr_font = Get_font(fnt);
  1191. X
  1192. X#ifdef DEBUG
  1193. X   dprintf(n)(stderr,"starting: (%d,%d)  %d x %d\r\n",x,y,dx,dy);
  1194. X#endif
  1195. X
  1196. X   if (dx < SUM_BDR + curr_font->head.wide*MIN_X +1 ||
  1197. X              dy < SUM_BDR + curr_font->head.high*MIN_Y +1)
  1198. X      return(0);
  1199. X   else
  1200. X      return(1);
  1201. X   }
  1202. X
  1203. X/* draw the window on the screen */
  1204. X
  1205. Xmake_window(screen,x,y,dx,dy,fnt,start)
  1206. XBITMAP *screen;
  1207. Xint x, y, dx, dy;
  1208. Xint fnt;
  1209. Xchar *start;
  1210. X   {
  1211. X   register WINDOW *win = active;
  1212. X   register int i;
  1213. X   struct font *curr_font, *Get_font();
  1214. X   char *last_tty();
  1215. X
  1216. X   if (dx<0)
  1217. X      x += dx, dx = -dx;
  1218. X   if (dy<0)
  1219. X      y += dy, dy = -dy;
  1220. X   
  1221. X   if (x < 0) x = 0;
  1222. X
  1223. X   if (x + dx >= BIT_WIDE(screen))
  1224. X      dx = BIT_WIDE(screen)-x;
  1225. X
  1226. X   if (y + dy >= BIT_HIGH(screen))
  1227. X      dy = BIT_HIGH(screen)-y;
  1228. X
  1229. X   curr_font = Get_font(fnt);
  1230. X   if (curr_font == font) {
  1231. X#ifdef DEBUG
  1232. X      dprintf(n)(stderr,"Can't find font %d, using default\r\n", fnt);
  1233. X#endif
  1234. X      }
  1235. X
  1236. X#ifdef DEBUG
  1237. X   dprintf(n)(stderr,"starting window: (%d,%d)  %d x %d font (%d,%d)\r\n",
  1238. X             x,y,dx,dy,curr_font->head.wide, curr_font->head.high);
  1239. X   dprintf(n)(stderr,"min size: %d x %d\r\n",
  1240. X           SUM_BDR + curr_font->head.wide*MIN_X +1,
  1241. X           SUM_BDR + curr_font->head.high*MIN_Y +1);
  1242. X#endif
  1243. X
  1244. X   if (dx < SUM_BDR + curr_font->head.wide*MIN_X +1 ||
  1245. X       dy < SUM_BDR + curr_font->head.high*MIN_Y +1)
  1246. X       return(-1);
  1247. X
  1248. X#ifdef DEBUG
  1249. X   dprintf(n)(stderr,"adjusted to: (%d,%d)  %d x %d\r\n",x,y,dx,dy);
  1250. X#endif
  1251. X
  1252. X   if (!setup_window(win,curr_font,x,y,dx,dy)) {
  1253. X      fprintf(stderr,"Out of memory for window creation -- bye!\n");
  1254. X      quit();
  1255. X      }
  1256. X
  1257. X   next_window++;
  1258. X
  1259. X   /* make the window */
  1260. X
  1261. X   set_covered(win);
  1262. X   border(win,BLK_BDR,WH_BDR);
  1263. X   CLEAR(W(window),BIT_CLR);
  1264. X
  1265. X   /* set up file descriptor modes */
  1266. X
  1267. X   if (fcntl(W(from_fd),F_SETFL,fcntl(W(from_fd),F_GETFL,0)|FNDELAY) == -1)
  1268. X      fprintf(stderr,"%s: fcntl failed for fd %d\n",W(tty),W(from_fd));
  1269. X
  1270. X   mask |= 1<<W(to_fd);
  1271. X
  1272. X   /* send initial string (if any) */
  1273. X
  1274. X   if (start && *start) {
  1275. X#ifdef DEBUG
  1276. X      dprintf(n)(stderr,"Sending initial string: [%s]\n",start);
  1277. X#endif
  1278. X      Write(W(to_fd),start,strlen(start));
  1279. X      }
  1280. X   return(0);
  1281. X   }
  1282. X
  1283. X/* initialize window state */
  1284. X
  1285. Xint
  1286. Xsetup_window(win,curr_font,x,y,dx,dy)
  1287. Xregister WINDOW *win;
  1288. Xint x,y,dx,dy;
  1289. Xstruct font *curr_font;
  1290. X   {
  1291. X   register int i;
  1292. X
  1293. X#ifdef ALIGN
  1294. X   alignwin(screen,&x,&dx,SUM_BDR);
  1295. X#endif
  1296. X
  1297. X   W(font) = curr_font;
  1298. X   W(x) = 0;
  1299. X   W(y) = curr_font->head.high;
  1300. X   W(esc_cnt) = 0;
  1301. X   W(esc[0]) = 0;
  1302. X   W(flags) = W_ACTIVE | init_flags;
  1303. X#ifdef CUT
  1304. X   W(flags) |= W_SNARFABLE;
  1305. X#endif
  1306. X#ifdef COLOR
  1307. X   W(background) = NOCOLOR&BIT_SRC | GETCOLOR(WHITE);
  1308. X   W(style) = NOCOLOR&BIT_SRC | GETCOLOR(BLACK);
  1309. X#else
  1310. X   W(style) = OPCODE(BIT_SRC);
  1311. X   W(background) = OPCODE(BIT_CLR);
  1312. X#endif
  1313. X    W(curs_type) = CS_BLOCK;
  1314. X   W(x0) = x;
  1315. X   W(y0) = y;
  1316. X   W(border) = bit_create(screen,x,y,dx,dy);
  1317. X   W(window) = bit_create(W(border),SUM_BDR,SUM_BDR,dx-SUM_BDR*2,dy-SUM_BDR*2);
  1318. X
  1319. X   W(text.x) = 0;
  1320. X   W(text.y) = 0;
  1321. X   W(text.wide) = 0;
  1322. X   W(text.high) = 0;
  1323. X
  1324. X   W(bitmap) = (BITMAP *) 0;
  1325. X   for(i=0;i<MAXBITMAPS;i++)
  1326. X      W(bitmaps)[i] = (BITMAP *) 0;
  1327. X
  1328. X   W(save) = (BITMAP *) 0;
  1329. X   W(stack) = (WINDOW *) 0;
  1330. X   W(main) = win;
  1331. X   W(alt) = (WINDOW *) 0;
  1332. X   W(esc_cnt) = 0;
  1333. X   W(esc[0])=0;
  1334. X   W(clip_list) = (char *) 0;
  1335. X
  1336. X   for(i=0;i<MAXMENU;i++)
  1337. X      W(menus[i]) = (struct menu_state *) 0;
  1338. X
  1339. X   W(menu[0]) = W(menu[1]) = -1;
  1340. X   W(event_mask) = 0;
  1341. X
  1342. X   for(i=0;i<MAXEVENTS;i++)
  1343. X      W(events)[i] = (char *) 0;
  1344. X
  1345. X   W(snarf) = (char *) 0;
  1346. X   W(gx) = 0;
  1347. X   W(gy) = 0;
  1348. X   W(op) = OPCODE(BIT_SET);
  1349. X   W(max) = 0;
  1350. X   W(current) = 0;
  1351. X   strcpy(W(tty), last_tty());
  1352. X   W(num) = 0;
  1353. X   clip_bad(win);    /* invalidate clip lists */
  1354. X   return(W(border) && W(window));
  1355. X   }
  1356. X
  1357. X/*
  1358. X    Look through all the windows for the next available window set id.
  1359. X*/
  1360. X
  1361. Xint
  1362. Xnext_windowset_id()
  1363. X   {
  1364. X      char        list[ MAXWIN + 2 ];
  1365. X      register char    *cp;
  1366. X      register WINDOW    *win;
  1367. X
  1368. X      for( cp = list;  cp < &list[ MAXWIN + 2 ];  cp++ )
  1369. X     *cp = 0;
  1370. X
  1371. X      for( win = active;  win != (WINDOW *)0;  win = W(next) )
  1372. X     list[ W(setid) ] = 1;
  1373. X
  1374. X      /*    There is no window set ID zero.
  1375. X      */
  1376. X      for( cp = list + 1;  *cp;  cp++ )
  1377. X     ;
  1378. X
  1379. X      return cp - list;
  1380. X   }
  1381. END_OF_FILE
  1382. # end of 'src/new_window.c'
  1383. fi
  1384. if test -f 'src/update.c' -a "${1}" != "-c" ; then 
  1385.   echo shar: Will not clobber existing file \"'src/update.c'\"
  1386. else
  1387. echo shar: Extracting \"'src/update.c'\" \(7972 characters\)
  1388. sed "s/^X//" >'src/update.c' <<'END_OF_FILE'
  1389. X/*                        Copyright (c) 1988 Bellcore
  1390. X *                            All Rights Reserved
  1391. X *       Permission is granted to copy or use this program, EXCEPT that it
  1392. X *       may not be sold for profit, the copyright notice must be reproduced
  1393. X *       on copies, and credit should be given to Bellcore where it is due.
  1394. X *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  1395. X */
  1396. X/*    $Header: update.c,v 4.1 88/06/21 13:34:49 bianchi Exp $
  1397. X    $Source: /tmp/mgrsrc/src/RCS/update.c,v $
  1398. X*/
  1399. Xstatic char    RCSid_[] = "$Source: /tmp/mgrsrc/src/RCS/update.c,v $$Revision: 4.1 $";
  1400. X
  1401. X/* update a background window */
  1402. X
  1403. X/*
  1404. X *       build a clip list
  1405. X *    1) find all window edges that intersect with the current window 
  1406. X *    2) sort all tops+bottoms then left+rights into increasing order
  1407. X *    3) for each rectangular patch, see if it is visible on target window
  1408. X *    4) if visible, coellesce patch and keep on a list
  1409. X *    update window against clip list
  1410. X * 5) run through list, and update each rext that intersects with
  1411. X *    the clip region
  1412. X */
  1413. X
  1414. X#include "bitmap.h"
  1415. X#include "defs.h"
  1416. X#include "clip.h"
  1417. X#include <stdio.h>
  1418. X
  1419. X#define MAX_COORDS    ((MAXWIN+1)  * 5)    /* educated guess (stab in the dark?) */
  1420. X
  1421. Xstruct rect_list {                /* list of visible "patches" of obscured window */
  1422. X    rectangle rect;                /* clipping rectangle */
  1423. X    struct rect_list *next;        /* next clipping rectangle */
  1424. X    };
  1425. X
  1426. Xstatic int x[MAX_COORDS];        /* left/right edges of covering windows */
  1427. Xstatic int y[MAX_COORDS];        /* top/bottom edges of covering windows */
  1428. X
  1429. X/* update an obscured window */
  1430. X
  1431. Xupdate(win, clipp)
  1432. Xregister WINDOW *win;
  1433. Xrect    *clipp;
  1434. X    {
  1435. X    /* generate clip list */
  1436. X
  1437. X    if (!(W(flags)&W_CLIPDONE)) {
  1438. X        if (W(clip_list) != NULL) /* free old list (we could reuse it) */
  1439. X            zap_cliplist(win);
  1440. X        gen_list(win);
  1441. X        W(flags) |= W_CLIPDONE;
  1442. X        }
  1443. X
  1444. X    /* update the window */
  1445. X
  1446. X   do_update(win,clipp);            /* do the update */
  1447. X    }
  1448. X
  1449. X/* free window's clip list */
  1450. X
  1451. Xint
  1452. Xzap_cliplist(win)
  1453. XWINDOW *win;
  1454. X    {
  1455. X    register struct rect_list *list = (struct rect_list *) W(clip_list);
  1456. X    register struct rect_list *next;
  1457. X
  1458. X#ifdef DEBUG
  1459. X    dprintf(U)(stderr,"Zapping clip list\r\n");
  1460. X#endif
  1461. X    for(;list;list=next) {
  1462. X        next = list->next;
  1463. X        free(list);
  1464. X        }    
  1465. X    W(clip_list) = NULL;
  1466. X    }
  1467. X
  1468. X/* generate a clip list */
  1469. X
  1470. Xint
  1471. Xgen_list(window)
  1472. Xregister WINDOW *window;
  1473. X   {
  1474. X
  1475. X   register WINDOW *win = window;
  1476. X   register struct rect_list *list, *prev = (struct rect_list *)0;
  1477. X   register int x_cnt = 2, y_cnt = 2;
  1478. X   register int i, j;
  1479. X   int count = 0;
  1480. X   int skip;        /* covered by another window - skip patch */
  1481. X   int hold;        /* hold for coellessing */
  1482. X
  1483. X   int cmp();        /* compare for qsort */
  1484. X
  1485. X   /* build arrays of window coordinates: intersecting win's above win */
  1486. X
  1487. X   x[0] = SUM_BDR + W(x0);
  1488. X   y[0] = SUM_BDR + W(y0);
  1489. X   x[1] = SUM_BDR + W(x0) + BIT_WIDE(W(window));
  1490. X   y[1] = SUM_BDR + W(y0) + BIT_HIGH(W(window));
  1491. X
  1492. X   for(win = active; win != window; win=W(next)) {
  1493. X      if (!(in_win(win,x[0],y[0],x[1],y[1])))
  1494. X         continue;
  1495. X
  1496. X      if (W(x0) >= x[0] && W(x0) <= x[1])
  1497. X         x[x_cnt++] = W(x0);
  1498. X
  1499. X      if (W(y0) >= y[0] && W(y0) <= y[1])
  1500. X         y[y_cnt++] = W(y0);
  1501. X
  1502. X      if (W(x0) + BIT_WIDE(W(border)) >= x[0] &&
  1503. X               W(x0) + BIT_WIDE(W(border)) <= x[1])
  1504. X         x[x_cnt++] = W(x0) + BIT_WIDE(W(border));
  1505. X
  1506. X      if (W(y0) + BIT_HIGH(W(border)) >= y[0] &&
  1507. X               W(y0) + BIT_HIGH(W(border)) <= y[1])
  1508. X         y[y_cnt++] = W(y0) + BIT_HIGH(W(border));
  1509. X      
  1510. X      if (y_cnt >= MAX_COORDS || x_cnt >= MAX_COORDS)
  1511. X         break;
  1512. X      }
  1513. X
  1514. X   /* sort window coordinate lists */
  1515. X
  1516. X   qsort(x,x_cnt,sizeof(int),cmp);
  1517. X   qsort(y,y_cnt,sizeof(int),cmp);
  1518. X
  1519. X   x_cnt--;
  1520. X   y_cnt--;
  1521. X
  1522. X   /* build list of covering rectangles */
  1523. X
  1524. X   for(j=0; j<y_cnt; j++) {
  1525. X
  1526. X      if (y[j] == y[j+1])    /* avoid zero-height patches */
  1527. X         continue;
  1528. X
  1529. X      for(hold=x_cnt,i=0; i<x_cnt; i++) {
  1530. X
  1531. X         if (x[i] == x[i+1])    /* avoid zero-width patches */
  1532. X            continue;
  1533. X
  1534. X            /* see if patch is visible */
  1535. X
  1536. X         for(skip=0,win=active; win!=window; win=W(next))
  1537. X            if (in_win(win, x[i], y[j], x[i+1], y[j+1])) {
  1538. X               skip++;
  1539. X               break;
  1540. X               }
  1541. X
  1542. X            /* visible, add patch to list, or append to previous patch */
  1543. X
  1544. X         if (!skip)  {
  1545. X                if (i == hold) {        /* coel. across */
  1546. X                    list->rect.wide += x[i+1] - x[i];
  1547. X                    hold++;
  1548. X                    }
  1549. X                else {    /* flush held rect */
  1550. X                    count++;        /* only for debugging */
  1551. X                    list = (struct rect_list *) alloc(sizeof(struct rect_list));
  1552. X                    list->rect.x = x[i] - W(x0);
  1553. X                    list->rect.y = y[j] - W(y0);
  1554. X                    list->rect.wide = x[i+1] - x[i];
  1555. X                    list->rect.high = y[j+1] - y[j];
  1556. X                    list -> next = NULL;
  1557. X                    if (prev)
  1558. X                        prev -> next = list;
  1559. X                    if (!W(clip_list))    /* set initial rectangle */
  1560. X                        W(clip_list) = (char *) list;
  1561. X                    prev = list;
  1562. X                    hold = i+1;                /* next 'i' to check for coell. */
  1563. X                    }
  1564. X            }
  1565. X         }
  1566. X      }
  1567. X
  1568. X/* look at rect list    DEBUG code, commented out!
  1569. X
  1570. X    for(list=(struct rect_list *) W(clip_list);list;list = list->next) {
  1571. X        int    x = list->rect.x,
  1572. X            y = list->rect.y,
  1573. X            wide = list->rect.wide,
  1574. X            high = list->rect.high;
  1575. X        in_mouseoff( x, y, wide, high );
  1576. X        bit_blit(W(border), x, y, wide, high, BIT_NOT(BIT_DST),0L,0,0);
  1577. X        dprintf(U)(stderr,"  Rect %d,%d  %dx%d\n", x, y, wide, high );
  1578. X        getchar();
  1579. X        bit_blit(W(border), x, y, wide, high, BIT_NOT(BIT_DST),0L,0,0);
  1580. X        MOUSE_ON(mousex,mousey);
  1581. X        }
  1582. XDEBUG code, commented out! */
  1583. X
  1584. X#ifdef DEBUG
  1585. X    dprintf(U)(stderr,"%s: Built clip list (%d)\r\n",W(tty),count);
  1586. X#endif
  1587. X
  1588. X    return(0);    /* I'll think of something */
  1589. X   }
  1590. X
  1591. X/* update obscured window */
  1592. X
  1593. Xint
  1594. Xdo_update(win,clipp)    
  1595. Xregister WINDOW *win;    /* window to update */
  1596. Xrect *clipp;          /* region of window to update (window coords) */
  1597. X    {
  1598. X   register struct rect_list *list;    /* list of rectangle to clip to */
  1599. X   register rectangle *got;        /* intersecting region */
  1600. X   rectangle *got_int();        /* finds intersecting rectangle */
  1601. X
  1602. X#ifdef DEBUG
  1603. X    dprintf(*)(stderr,"Updating background window to %d,%d => %d,%d\r\n",
  1604. X        clipp->x1,clipp->y1,clipp->x2,clipp->y2);
  1605. X#endif
  1606. X
  1607. X    for(list=(struct rect_list *)W(clip_list);list;list = list->next) {
  1608. X        if (got = got_int(&(list->rect),clipp)) {
  1609. X            register int    x = got->x,
  1610. X                    y = got->y,
  1611. X                    wide = got->wide,
  1612. X                    high = got->high;
  1613. X            in_mouseoff( x + W(x0), y + W(y0), wide, high );
  1614. X            bit_blit(W(border),x,y,wide,high,BIT_SRC,W(save),x,y);
  1615. X            MOUSE_ON(mousex,mousey);
  1616. X            }
  1617. X        }
  1618. X    }
  1619. X
  1620. X/* find the intersection of 2 rectangles */
  1621. X
  1622. Xrectangle *
  1623. Xgot_int(r1,r2)
  1624. Xregister rectangle *r1;        /* rect 1 */
  1625. Xregister rect *r2;            /* other rect   (should both be same struct) */
  1626. X    {
  1627. X    static rectangle result;
  1628. X
  1629. X    result.x = Max(r1->x,r2->x1+SUM_BDR);
  1630. X    result.y = Max(r1->y,r2->y1+SUM_BDR);
  1631. X    result.wide = Min(r1->x + r1->wide, r2->x2+SUM_BDR) - result.x;
  1632. X    result.high = Min(r1->y + r1->high, r2->y2+SUM_BDR) - result.y;
  1633. X
  1634. X    if (result.wide > 0 && result.high > 0 )
  1635. X      return(&result);
  1636. X    else
  1637. X        return((rectangle *) 0);
  1638. X    }
  1639. X
  1640. X/* see if mouse in rectangle, if so turn the mouse off */
  1641. X
  1642. Xin_mouseoff(x0,y0,wide,high)
  1643. Xregister int x0,y0,wide,high;
  1644. X   {
  1645. X   if( !( x0 > mousex+16 || y0 > mousey+16 ||
  1646. X        x0+wide < mousex || y0+high < mousey))
  1647. X    MOUSE_OFF(mousex,mousey);
  1648. X   }
  1649. X         
  1650. X/* see if rectangle in window */
  1651. X
  1652. Xint
  1653. Xin_win(win,x0,y0,x1,y1)
  1654. Xregister WINDOW *win;
  1655. Xregister x0,y0,x1,y1;
  1656. X   {
  1657. X   return(
  1658. X      W(x0) + BIT_WIDE(W(border)) <= x0 ||
  1659. X      x1 <= W(x0) ||
  1660. X      W(y0) + BIT_HIGH(W(border)) <= y0 ||
  1661. X      y1 <= W(y0)
  1662. X   ?  0  :  1);
  1663. X   }
  1664. X
  1665. X/* compare for qsort */
  1666. X
  1667. Xint
  1668. Xcmp(x,y)
  1669. Xint *x, *y;
  1670. X   {
  1671. X   return( *x - *y);
  1672. X   }
  1673. X
  1674. X/* invalidate clip list for all windows affected by 'window' */
  1675. X
  1676. Xclip_bad(window)
  1677. Xregister WINDOW *window;        /* this window has changed */
  1678. X    {
  1679. X    register WINDOW *win;        /* working window */
  1680. X
  1681. X    /* invalidate all intersecting window clip lists below this one */
  1682. X
  1683. X    window->flags &= ~W_CLIPDONE;        /* invalidate clip list */
  1684. X   for(win=window->next;win != (WINDOW *) 0;win=W(next))
  1685. X        if (intersect(win,window)) 
  1686. X            W(flags) &= ~W_CLIPDONE;        /* invalidate clip list */
  1687. X    }
  1688. END_OF_FILE
  1689. # end of 'src/update.c'
  1690. fi
  1691. echo shar: End of archive 28 \(of 61\).
  1692. cp /dev/null ark28isdone
  1693. MISSING=""
  1694. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
  1695.     21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 \
  1696.     38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 \
  1697.     55 56 57 58 59 60 61 ; do
  1698.     if test ! -f ark${I}isdone ; then
  1699.     MISSING="${MISSING} ${I}"
  1700.     fi
  1701. done
  1702. if test "${MISSING}" = "" ; then
  1703.     echo You have unpacked all 61 archives.
  1704.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1705. else
  1706.     echo You still need to unpack the following archives:
  1707.     echo "        " ${MISSING}
  1708. fi
  1709. ##  End of shell archive.
  1710. exit 0
  1711.